//
//  WSCustomButton.m
//  LANGirl
//
//  Created by 吴帅 on 16/3/26.
//
//

#import "WSCustomButton.h"

@implementation WSCustomButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addObserver:self forKeyPath:@"highlighted" options:NSKeyValueObservingOptionOld context:nil];
        self.tintColor = [UIColor whiteColor];
        [self addTarget:self action:@selector(aa) forControlEvents:UIControlEventTouchDown];
        NSLog(@"%lu", self.state);
    }
    return self;
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if([keyPath isEqualToString:@"highlighted"])
    {
        if (self.highlighted == YES) {
            self.tintColor = [UIColor whiteColor];
            self.layer.borderColor = [UIColor colorWithRed:0.75 green:0.72 blue:0.49 alpha:1].CGColor;
        }
        else {
           // self.tintColor = [UIColor blackColor];
            self.tintColor = [UIColor whiteColor];
            self.layer.borderColor = HS.CGColor;
        }
        
    }
}

- (void)dealloc {

    [self removeObserver:self forKeyPath:@"highlighted"];
    
}

- (void)aa {

    NSLog(@"%lu", self.state);
}

@end
